/* EOS Institute LUCIFair - Live

Using parameters: {"page":"main","logged":"0","destroy_all":"1","partner":"eos","project":"orgasmservice","lang":"en"}
array (
  'page' => 'main',
  'logged' => '0',
  'destroy_all' => '1',
  'partner' => 'eos',
  'project' => 'orgasmservice',
  'lang' => 'en',
)
*/
/*
    http://www.JSON.org/json2.js
    2010-03-20

    Public Domain.

    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.

    See http://www.JSON.org/js.html


    This code should be minified before deployment.
    See http://javascript.crockford.com/jsmin.html

    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
    NOT CONTROL.


    This file creates a global JSON object containing two methods: stringify
    and parse.

        JSON.stringify(value, replacer, space)
            value       any JavaScript value, usually an object or array.

            replacer    an optional parameter that determines how object
                        values are stringified for objects. It can be a
                        function or an array of strings.

            space       an optional parameter that specifies the indentation
                        of nested structures. If it is omitted, the text will
                        be packed without extra whitespace. If it is a number,
                        it will specify the number of spaces to indent at each
                        level. If it is a string (such as '\t' or '&nbsp;'),
                        it contains the characters used to indent at each level.

            This method produces a JSON text from a JavaScript value.

            When an object value is found, if the object contains a toJSON
            method, its toJSON method will be called and the result will be
            stringified. A toJSON method does not serialize: it returns the
            value represented by the name/value pair that should be serialized,
            or undefined if nothing should be serialized. The toJSON method
            will be passed the key associated with the value, and this will be
            bound to the value

            For example, this would serialize Dates as ISO strings.

                Date.prototype.toJSON = function (key) {
                    function f(n) {
                        // Format integers to have at least two digits.
                        return n < 10 ? '0' + n : n;
                    }

                    return this.getUTCFullYear()   + '-' +
                         f(this.getUTCMonth() + 1) + '-' +
                         f(this.getUTCDate())      + 'T' +
                         f(this.getUTCHours())     + ':' +
                         f(this.getUTCMinutes())   + ':' +
                         f(this.getUTCSeconds())   + 'Z';
                };

            You can provide an optional replacer method. It will be passed the
            key and value of each member, with this bound to the containing
            object. The value that is returned from your method will be
            serialized. If your method returns undefined, then the member will
            be excluded from the serialization.

            If the replacer parameter is an array of strings, then it will be
            used to select the members to be serialized. It filters the results
            such that only members with keys listed in the replacer array are
            stringified.

            Values that do not have JSON representations, such as undefined or
            functions, will not be serialized. Such values in objects will be
            dropped; in arrays they will be replaced with null. You can use
            a replacer function to replace those with JSON values.
            JSON.stringify(undefined) returns undefined.

            The optional space parameter produces a stringification of the
            value that is filled with line breaks and indentation to make it
            easier to read.

            If the space parameter is a non-empty string, then that string will
            be used for indentation. If the space parameter is a number, then
            the indentation will be that many spaces.

            Example:

            text = JSON.stringify(['e', {pluribus: 'unum'}]);
            // text is '["e",{"pluribus":"unum"}]'


            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'

            text = JSON.stringify([new Date()], function (key, value) {
                return this[key] instanceof Date ?
                    'Date(' + this[key] + ')' : value;
            });
            // text is '["Date(---current time---)"]'


        JSON.parse(text, reviver)
            This method parses a JSON text to produce an object or array.
            It can throw a SyntaxError exception.

            The optional reviver parameter is a function that can filter and
            transform the results. It receives each of the keys and values,
            and its return value is used instead of the original value.
            If it returns what it received, then the structure is not modified.
            If it returns undefined then the member is deleted.

            Example:

            // Parse the text. Values that look like ISO date strings will
            // be converted to Date objects.

            myData = JSON.parse(text, function (key, value) {
                var a;
                if (typeof value === 'string') {
                    a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
                    if (a) {
                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
                            +a[5], +a[6]));
                    }
                }
                return value;
            });

            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
                var d;
                if (typeof value === 'string' &&
                        value.slice(0, 5) === 'Date(' &&
                        value.slice(-1) === ')') {
                    d = new Date(value.slice(5, -1));
                    if (d) {
                        return d;
                    }
                }
                return value;
            });


    This is a reference implementation. You are free to copy, modify, or
    redistribute.
*/

/*jslint evil: true, strict: false */

/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
    lastIndex, length, parse, prototype, push, replace, slice, stringify,
    test, toJSON, toString, valueOf
*/


// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.

if (!this.JSON) {
    this.JSON = {};
}

(function () {

    function f(n) {
        // Format integers to have at least two digits.
        return n < 10 ? '0' + n : n;
    }

    if (typeof Date.prototype.toJSON !== 'function') {

        Date.prototype.toJSON = function (key) {

            return isFinite(this.valueOf()) ?
                   this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z' : null;
        };

        String.prototype.toJSON =
        Number.prototype.toJSON =
        Boolean.prototype.toJSON = function (key) {
            return this.valueOf();
        };
    }

    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        gap,
        indent,
        meta = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        rep;


    function quote(string) {

// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.

        escapable.lastIndex = 0;
        return escapable.test(string) ?
            '"' + string.replace(escapable, function (a) {
                var c = meta[a];
                return typeof c === 'string' ? c :
                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
            }) + '"' :
            '"' + string + '"';
    }


    function str(key, holder) {

// Produce a string from holder[key].

        var i,          // The loop counter.
            k,          // The member key.
            v,          // The member value.
            length,
            mind = gap,
            partial,
            value = holder[key];

// If the value has a toJSON method, call it to obtain a replacement value.

        if (value && typeof value === 'object' &&
                typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }

// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.

        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }

// What happens next depends on the value's type.

        switch (typeof value) {
        case 'string':
            return quote(value);

        case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

            return isFinite(value) ? String(value) : 'null';

        case 'boolean':
        case 'null':

// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.

            return String(value);

// If the type is 'object', we might be dealing with an object or an array or
// null.

        case 'object':

// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.

            if (!value) {
                return 'null';
            }

// Make an array to hold the partial results of stringifying this object value.

            gap += indent;
            partial = [];

// Is the value an array?

            if (Object.prototype.toString.apply(value) === '[object Array]') {

// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                length = value.length;
                for (i = 0; i < length; i += 1) {
                    partial[i] = str(i, value) || 'null';
                }

// Join all of the elements together, separated with commas, and wrap them in
// brackets.

                v = partial.length === 0 ? '[]' :
                    gap ? '[\n' + gap +
                            partial.join(',\n' + gap) + '\n' +
                                mind + ']' :
                          '[' + partial.join(',') + ']';
                gap = mind;
                return v;
            }

// If the replacer is an array, use it to select the members to be stringified.

            if (rep && typeof rep === 'object') {
                length = rep.length;
                for (i = 0; i < length; i += 1) {
                    k = rep[i];
                    if (typeof k === 'string') {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            } else {

// Otherwise, iterate through all of the keys in the object.

                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            }

// Join all of the member texts together, separated with commas,
// and wrap them in braces.

            v = partial.length === 0 ? '{}' :
                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
                        mind + '}' : '{' + partial.join(',') + '}';
            gap = mind;
            return v;
        }
    }

// If the JSON object does not yet have a stringify method, give it one.

    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function (value, replacer, space) {

// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.

            var i;
            gap = '';
            indent = '';

// If the space parameter is a number, make an indent string containing that
// many spaces.

            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    indent += ' ';
                }

// If the space parameter is a string, it will be used as the indent string.

            } else if (typeof space === 'string') {
                indent = space;
            }

// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.

            rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                    (typeof replacer !== 'object' ||
                     typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }

// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.

            return str('', {'': value});
        };
    }


// If the JSON object does not yet have a parse method, give it one.

    if (typeof JSON.parse !== 'function') {
        JSON.parse = function (text, reviver) {

// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.

            var j;

            function walk(holder, key) {

// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.

                var k, v, value = holder[key];
                if (value && typeof value === 'object') {
                    for (k in value) {
                        if (Object.hasOwnProperty.call(value, k)) {
                            v = walk(value, k);
                            if (v !== undefined) {
                                value[k] = v;
                            } else {
                                delete value[k];
                            }
                        }
                    }
                }
                return reviver.call(holder, key, value);
            }


// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.

            text = String(text);
            cx.lastIndex = 0;
            if (cx.test(text)) {
                text = text.replace(cx, function (a) {
                    return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }

// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.

// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

            if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.

                j = eval('(' + text + ')');

// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.

                return typeof reviver === 'function' ?
                    walk({'': j}, '') : j;
            }

// If the text is not JSON parseable, then a SyntaxError is thrown.

            throw new SyntaxError('JSON.parse');
        };
    }
}());
(function(){var a;function diff_match_patch(){function b(){for(var c=0,e=1,d=2;e!=d;){c++;e=d;d<<=1}return c}this.Diff_Timeout=1;this.Diff_EditCost=4;this.Diff_DualThreshold=32;this.Match_Threshold=0.5;this.Match_Distance=1E3;this.Patch_DeleteThreshold=0.5;this.Patch_Margin=4;this.Match_MaxBits=b()}a=diff_match_patch.prototype;
a.diff_main=function(b,c,e){if(b==null||c==null)throw Error("Null input. (diff_main)");if(b==c)return[[0,b]];if(typeof e=="undefined")e=true;var d=e,f=this.diff_commonPrefix(b,c);e=b.substring(0,f);b=b.substring(f);c=c.substring(f);f=this.diff_commonSuffix(b,c);var g=b.substring(b.length-f);b=b.substring(0,b.length-f);c=c.substring(0,c.length-f);b=this.diff_compute(b,c,d);e&&b.unshift([0,e]);g&&b.push([0,g]);this.diff_cleanupMerge(b);return b};
a.diff_compute=function(b,c,e){var d;if(!b)return[[1,c]];if(!c)return[[-1,b]];d=b.length>c.length?b:c;var f=b.length>c.length?c:b,g=d.indexOf(f);if(g!=-1){d=[[1,d.substring(0,g)],[0,f],[1,d.substring(g+f.length)]];if(b.length>c.length)d[0][0]=d[2][0]=-1;return d}if(d=this.diff_halfMatch(b,c)){var h=d[0];b=d[1];f=d[2];c=d[3];d=d[4];h=this.diff_main(h,f,e);e=this.diff_main(b,c,e);return h.concat([[0,d]],e)}if(e&&(b.length<100||c.length<100))e=false;if(e){h=this.diff_linesToChars(b,c);b=h[0];c=h[1];
h=h[2]}(d=this.diff_map(b,c))||(d=[[-1,b],[1,c]]);if(e){this.diff_charsToLines(d,h);this.diff_cleanupSemantic(d);d.push([0,""]);c=b=e=0;for(f=h="";e<d.length;){switch(d[e][0]){case 1:c++;f+=d[e][1];break;case -1:b++;h+=d[e][1];break;case 0:if(b>=1&&c>=1){h=this.diff_main(h,f,false);d.splice(e-b-c,b+c);e=e-b-c;for(b=h.length-1;b>=0;b--)d.splice(e,0,h[b]);e+=h.length}b=c=0;f=h="";break}e++}d.pop()}return d};
a.diff_linesToChars=function(b,c){function e(i){for(var k="",j=0,l=-1,m=d.length;l<i.length-1;){l=i.indexOf("\n",j);if(l==-1)l=i.length-1;var p=i.substring(j,l+1);j=l+1;if(f.hasOwnProperty?f.hasOwnProperty(p):f[p]!==undefined)k+=String.fromCharCode(f[p]);else{k+=String.fromCharCode(m);f[p]=m;d[m++]=p}}return k}var d=[],f={};d[0]="";var g=e(b),h=e(c);return[g,h,d]};
a.diff_charsToLines=function(b,c){for(var e=0;e<b.length;e++){for(var d=b[e][1],f=[],g=0;g<d.length;g++)f[g]=c[d.charCodeAt(g)];b[e][1]=f.join("")}};
a.diff_map=function(b,c){var e=(new Date).getTime()+this.Diff_Timeout*1E3,d=b.length,f=c.length,g=d+f-1,h=this.Diff_DualThreshold*2<g,i=[],k=[],j={},l={};j[1]=0;l[1]=0;for(var m,p,n,o={},s=false,u=!!o.hasOwnProperty,t=(d+f)%2,q=0;q<g;q++){if(this.Diff_Timeout>0&&(new Date).getTime()>e)return null;i[q]={};for(var r=-q;r<=q;r+=2){m=r==-q||r!=q&&j[r-1]<j[r+1]?j[r+1]:j[r-1]+1;p=m-r;if(h){n=m+","+p;if(t&&(u?o.hasOwnProperty(n):o[n]!==undefined))s=true;t||(o[n]=q)}for(;!s&&m<d&&p<f&&b.charAt(m)==c.charAt(p);){m++;
p++;if(h){n=m+","+p;if(t&&(u?o.hasOwnProperty(n):o[n]!==undefined))s=true;t||(o[n]=q)}}j[r]=m;i[q][m+","+p]=true;if(m==d&&p==f)return this.diff_path1(i,b,c);else if(s){k=k.slice(0,o[n]+1);e=this.diff_path1(i,b.substring(0,m),c.substring(0,p));return e.concat(this.diff_path2(k,b.substring(m),c.substring(p)))}}if(h){k[q]={};for(r=-q;r<=q;r+=2){m=r==-q||r!=q&&l[r-1]<l[r+1]?l[r+1]:l[r-1]+1;p=m-r;n=d-m+","+(f-p);if(!t&&(u?o.hasOwnProperty(n):o[n]!==undefined))s=true;if(t)o[n]=q;for(;!s&&m<d&&p<f&&b.charAt(d-
m-1)==c.charAt(f-p-1);){m++;p++;n=d-m+","+(f-p);if(!t&&(u?o.hasOwnProperty(n):o[n]!==undefined))s=true;if(t)o[n]=q}l[r]=m;k[q][m+","+p]=true;if(s){i=i.slice(0,o[n]+1);e=this.diff_path1(i,b.substring(0,d-m),c.substring(0,f-p));return e.concat(this.diff_path2(k,b.substring(d-m),c.substring(f-p)))}}}}return null};
a.diff_path1=function(b,c,e){for(var d=[],f=c.length,g=e.length,h=null,i=b.length-2;i>=0;i--)for(;;)if(b[i].hasOwnProperty?b[i].hasOwnProperty(f-1+","+g):b[i][f-1+","+g]!==undefined){f--;if(h===-1)d[0][1]=c.charAt(f)+d[0][1];else d.unshift([-1,c.charAt(f)]);h=-1;break}else if(b[i].hasOwnProperty?b[i].hasOwnProperty(f+","+(g-1)):b[i][f+","+(g-1)]!==undefined){g--;if(h===1)d[0][1]=e.charAt(g)+d[0][1];else d.unshift([1,e.charAt(g)]);h=1;break}else{f--;g--;if(c.charCodeAt(f)!=e.charCodeAt(g))throw Error("No diagonal.  Can't happen. (diff_path1)");
if(h===0)d[0][1]=c.charAt(f)+d[0][1];else d.unshift([0,c.charAt(f)]);h=0}return d};
a.diff_path2=function(b,c,e){for(var d=[],f=0,g=c.length,h=e.length,i=null,k=b.length-2;k>=0;k--)for(;;)if(b[k].hasOwnProperty?b[k].hasOwnProperty(g-1+","+h):b[k][g-1+","+h]!==undefined){g--;if(i===-1)d[f-1][1]+=c.charAt(c.length-g-1);else d[f++]=[-1,c.charAt(c.length-g-1)];i=-1;break}else if(b[k].hasOwnProperty?b[k].hasOwnProperty(g+","+(h-1)):b[k][g+","+(h-1)]!==undefined){h--;if(i===1)d[f-1][1]+=e.charAt(e.length-h-1);else d[f++]=[1,e.charAt(e.length-h-1)];i=1;break}else{g--;h--;if(c.charCodeAt(c.length-
g-1)!=e.charCodeAt(e.length-h-1))throw Error("No diagonal.  Can't happen. (diff_path2)");if(i===0)d[f-1][1]+=c.charAt(c.length-g-1);else d[f++]=[0,c.charAt(c.length-g-1)];i=0}return d};a.diff_commonPrefix=function(b,c){if(!b||!c||b.charCodeAt(0)!==c.charCodeAt(0))return 0;for(var e=0,d=Math.min(b.length,c.length),f=d,g=0;e<f;){if(b.substring(g,f)==c.substring(g,f))g=e=f;else d=f;f=Math.floor((d-e)/2+e)}return f};
a.diff_commonSuffix=function(b,c){if(!b||!c||b.charCodeAt(b.length-1)!==c.charCodeAt(c.length-1))return 0;for(var e=0,d=Math.min(b.length,c.length),f=d,g=0;e<f;){if(b.substring(b.length-f,b.length-g)==c.substring(c.length-f,c.length-g))g=e=f;else d=f;f=Math.floor((d-e)/2+e)}return f};
a.diff_halfMatch=function(b,c){function e(j,l,m){for(var p=j.substring(m,m+Math.floor(j.length/4)),n=-1,o="",s,u,t,q;(n=l.indexOf(p,n+1))!=-1;){var r=g.diff_commonPrefix(j.substring(m),l.substring(n)),v=g.diff_commonSuffix(j.substring(0,m),l.substring(0,n));if(o.length<v+r){o=l.substring(n-v,n)+l.substring(n,n+r);s=j.substring(0,m-v);u=j.substring(m+r);t=l.substring(0,n-v);q=l.substring(n+r)}}return o.length>=j.length/2?[s,u,t,q,o]:null}var d=b.length>c.length?b:c,f=b.length>c.length?c:b;if(d.length<
10||f.length<1)return null;var g=this,h=e(d,f,Math.ceil(d.length/4));d=e(d,f,Math.ceil(d.length/2));var i;if(!h&&!d)return null;else i=d?h?h[4].length>d[4].length?h:d:d:h;var k;if(b.length>c.length){h=i[0];d=i[1];f=i[2];k=i[3]}else{f=i[0];k=i[1];h=i[2];d=i[3]}i=i[4];return[h,d,f,k,i]};
a.diff_cleanupSemantic=function(b){for(var c=false,e=[],d=0,f=null,g=0,h=0,i=0;g<b.length;){if(b[g][0]==0){e[d++]=g;h=i;i=0;f=b[g][1]}else{i+=b[g][1].length;if(f!==null&&f.length<=h&&f.length<=i){b.splice(e[d-1],0,[-1,f]);b[e[d-1]+1][0]=1;d--;d--;g=d>0?e[d-1]:-1;i=h=0;f=null;c=true}}g++}c&&this.diff_cleanupMerge(b);this.diff_cleanupSemanticLossless(b)};
a.diff_cleanupSemanticLossless=function(b){function c(u,t){if(!u||!t)return 5;var q=0;if(u.charAt(u.length-1).match(e)||t.charAt(0).match(e)){q++;if(u.charAt(u.length-1).match(d)||t.charAt(0).match(d)){q++;if(u.charAt(u.length-1).match(f)||t.charAt(0).match(f)){q++;if(u.match(g)||t.match(h))q++}}}return q}for(var e=/[^a-zA-Z0-9]/,d=/\s/,f=/[\r\n]/,g=/\n\r?\n$/,h=/^\r?\n\r?\n/,i=1;i<b.length-1;){if(b[i-1][0]==0&&b[i+1][0]==0){var k=b[i-1][1],j=b[i][1],l=b[i+1][1],m=this.diff_commonSuffix(k,j);if(m){var p=
j.substring(j.length-m);k=k.substring(0,k.length-m);j=p+j.substring(0,j.length-m);l=p+l}m=k;p=j;for(var n=l,o=c(k,j)+c(j,l);j.charAt(0)===l.charAt(0);){k+=j.charAt(0);j=j.substring(1)+l.charAt(0);l=l.substring(1);var s=c(k,j)+c(j,l);if(s>=o){o=s;m=k;p=j;n=l}}if(b[i-1][1]!=m){if(m)b[i-1][1]=m;else{b.splice(i-1,1);i--}b[i][1]=p;if(n)b[i+1][1]=n;else{b.splice(i+1,1);i--}}}i++}};
a.diff_cleanupEfficiency=function(b){for(var c=false,e=[],d=0,f="",g=0,h=false,i=false,k=false,j=false;g<b.length;){if(b[g][0]==0){if(b[g][1].length<this.Diff_EditCost&&(k||j)){e[d++]=g;h=k;i=j;f=b[g][1]}else{d=0;f=""}k=j=false}else{if(b[g][0]==-1)j=true;else k=true;if(f&&(h&&i&&k&&j||f.length<this.Diff_EditCost/2&&h+i+k+j==3)){b.splice(e[d-1],0,[-1,f]);b[e[d-1]+1][0]=1;d--;f="";if(h&&i){k=j=true;d=0}else{d--;g=d>0?e[d-1]:-1;k=j=false}c=true}}g++}c&&this.diff_cleanupMerge(b)};
a.diff_cleanupMerge=function(b){b.push([0,""]);for(var c=0,e=0,d=0,f="",g="",h;c<b.length;)switch(b[c][0]){case 1:d++;g+=b[c][1];c++;break;case -1:e++;f+=b[c][1];c++;break;case 0:if(e!==0||d!==0){if(e!==0&&d!==0){h=this.diff_commonPrefix(g,f);if(h!==0){if(c-e-d>0&&b[c-e-d-1][0]==0)b[c-e-d-1][1]+=g.substring(0,h);else{b.splice(0,0,[0,g.substring(0,h)]);c++}g=g.substring(h);f=f.substring(h)}h=this.diff_commonSuffix(g,f);if(h!==0){b[c][1]=g.substring(g.length-h)+b[c][1];g=g.substring(0,g.length-h);f=
f.substring(0,f.length-h)}}if(e===0)b.splice(c-e-d,e+d,[1,g]);else d===0?b.splice(c-e-d,e+d,[-1,f]):b.splice(c-e-d,e+d,[-1,f],[1,g]);c=c-e-d+(e?1:0)+(d?1:0)+1}else if(c!==0&&b[c-1][0]==0){b[c-1][1]+=b[c][1];b.splice(c,1)}else c++;e=d=0;g=f="";break}b[b.length-1][1]===""&&b.pop();e=false;for(c=1;c<b.length-1;){if(b[c-1][0]==0&&b[c+1][0]==0)if(b[c][1].substring(b[c][1].length-b[c-1][1].length)==b[c-1][1]){b[c][1]=b[c-1][1]+b[c][1].substring(0,b[c][1].length-b[c-1][1].length);b[c+1][1]=b[c-1][1]+b[c+
1][1];b.splice(c-1,1);e=true}else if(b[c][1].substring(0,b[c+1][1].length)==b[c+1][1]){b[c-1][1]+=b[c+1][1];b[c][1]=b[c][1].substring(b[c+1][1].length)+b[c+1][1];b.splice(c+1,1);e=true}c++}e&&this.diff_cleanupMerge(b)};a.diff_xIndex=function(b,c){var e=0,d=0,f=0,g=0,h;for(h=0;h<b.length;h++){if(b[h][0]!==1)e+=b[h][1].length;if(b[h][0]!==-1)d+=b[h][1].length;if(e>c)break;f=e;g=d}if(b.length!=h&&b[h][0]===-1)return g;return g+(c-f)};
a.diff_prettyHtml=function(b){for(var c=[],e=0,d=0;d<b.length;d++){var f=b[d][0],g=b[d][1],h=g.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"&para;<BR>");switch(f){case 1:c[d]='<INS STYLE="background:#E6FFE6;" TITLE="i='+e+'">'+h+"</INS>";break;case -1:c[d]='<DEL STYLE="background:#FFE6E6;" TITLE="i='+e+'">'+h+"</DEL>";break;case 0:c[d]='<SPAN TITLE="i='+e+'">'+h+"</SPAN>";break}if(f!==-1)e+=g.length}return c.join("")};
a.diff_text1=function(b){for(var c=[],e=0;e<b.length;e++)if(b[e][0]!==1)c[e]=b[e][1];return c.join("")};a.diff_text2=function(b){for(var c=[],e=0;e<b.length;e++)if(b[e][0]!==-1)c[e]=b[e][1];return c.join("")};a.diff_levenshtein=function(b){for(var c=0,e=0,d=0,f=0;f<b.length;f++){var g=b[f][0],h=b[f][1];switch(g){case 1:e+=h.length;break;case -1:d+=h.length;break;case 0:c+=Math.max(e,d);d=e=0;break}}c+=Math.max(e,d);return c};
a.diff_toDelta=function(b){for(var c=[],e=0;e<b.length;e++)switch(b[e][0]){case 1:c[e]="+"+encodeURI(b[e][1]);break;case -1:c[e]="-"+b[e][1].length;break;case 0:c[e]="="+b[e][1].length;break}return c.join("\t").replace(/\x00/g,"%00").replace(/%20/g," ")};
a.diff_fromDelta=function(b,c){var e=[],d=0,f=0;c=c.replace(/%00/g,"\u0000");for(var g=c.split(/\t/g),h=0;h<g.length;h++){var i=g[h].substring(1);switch(g[h].charAt(0)){case "+":try{e[d++]=[1,decodeURI(i)]}catch(k){throw Error("Illegal escape in diff_fromDelta: "+i);}break;case "-":case "=":var j=parseInt(i,10);if(isNaN(j)||j<0)throw Error("Invalid number in diff_fromDelta: "+i);i=b.substring(f,f+=j);if(g[h].charAt(0)=="=")e[d++]=[0,i];else e[d++]=[-1,i];break;default:if(g[h])throw Error("Invalid diff operation in diff_fromDelta: "+
g[h]);}}if(f!=b.length)throw Error("Delta length ("+f+") does not equal source text length ("+b.length+").");return e};a.match_main=function(b,c,e){if(b==null||c==null||e==null)throw Error("Null input. (match_main)");e=Math.max(0,Math.min(e,b.length));return b==c?0:b.length?b.substring(e,e+c.length)==c?e:this.match_bitap(b,c,e):-1};
a.match_bitap=function(b,c,e){function d(u,t){var q=u/c.length,r=Math.abs(e-t);if(!g.Match_Distance)return r?1:q;return q+r/g.Match_Distance}if(c.length>this.Match_MaxBits)throw Error("Pattern too long for this browser.");var f=this.match_alphabet(c),g=this,h=this.Match_Threshold,i=b.indexOf(c,e);if(i!=-1){h=Math.min(d(0,i),h);i=b.lastIndexOf(c,e+c.length);if(i!=-1)h=Math.min(d(0,i),h)}var k=1<<c.length-1;i=-1;for(var j,l,m=c.length+b.length,p,n=0;n<c.length;n++){j=0;for(l=m;j<l;){if(d(n,e+l)<=h)j=
l;else m=l;l=Math.floor((m-j)/2+j)}m=l;j=Math.max(1,e-l+1);var o=Math.min(e+l,b.length)+c.length;l=Array(o+2);l[o+1]=(1<<n)-1;for(o=o;o>=j;o--){var s=f[b.charAt(o-1)];l[o]=n===0?(l[o+1]<<1|1)&s:(l[o+1]<<1|1)&s|(p[o+1]|p[o])<<1|1|p[o+1];if(l[o]&k){s=d(n,o-1);if(s<=h){h=s;i=o-1;if(i>e)j=Math.max(1,2*e-i);else break}}}if(d(n+1,e)>h)break;p=l}return i};a.match_alphabet=function(b){for(var c={},e=0;e<b.length;e++)c[b.charAt(e)]=0;for(e=0;e<b.length;e++)c[b.charAt(e)]|=1<<b.length-e-1;return c};
a.patch_addContext=function(b,c){if(c.length!=0){for(var e=c.substring(b.start2,b.start2+b.length1),d=0;c.indexOf(e)!=c.lastIndexOf(e)&&e.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;){d+=this.Patch_Margin;e=c.substring(b.start2-d,b.start2+b.length1+d)}d+=this.Patch_Margin;(e=c.substring(b.start2-d,b.start2))&&b.diffs.unshift([0,e]);(d=c.substring(b.start2+b.length1,b.start2+b.length1+d))&&b.diffs.push([0,d]);b.start1-=e.length;b.start2-=e.length;b.length1+=e.length+d.length;b.length2+=
e.length+d.length}};
a.patch_make=function(b,c,e){var d;if(typeof b=="string"&&typeof c=="string"&&typeof e=="undefined"){d=b;c=this.diff_main(d,c,true);if(c.length>2){this.diff_cleanupSemantic(c);this.diff_cleanupEfficiency(c)}}else if(b&&typeof b=="object"&&typeof c=="undefined"&&typeof e=="undefined"){c=b;d=this.diff_text1(c)}else if(typeof b=="string"&&c&&typeof c=="object"&&typeof e=="undefined"){d=b;c=c}else if(typeof b=="string"&&typeof c=="string"&&e&&typeof e=="object"){d=b;c=e}else throw Error("Unknown call format to patch_make.");if(c.length===
0)return[];e=[];b=new patch_obj;var f=0,g=0,h=0,i=d;d=d;for(var k=0;k<c.length;k++){var j=c[k][0],l=c[k][1];if(!f&&j!==0){b.start1=g;b.start2=h}switch(j){case 1:b.diffs[f++]=c[k];b.length2+=l.length;d=d.substring(0,h)+l+d.substring(h);break;case -1:b.length1+=l.length;b.diffs[f++]=c[k];d=d.substring(0,h)+d.substring(h+l.length);break;case 0:if(l.length<=2*this.Patch_Margin&&f&&c.length!=k+1){b.diffs[f++]=c[k];b.length1+=l.length;b.length2+=l.length}else if(l.length>=2*this.Patch_Margin)if(f){this.patch_addContext(b,
i);e.push(b);b=new patch_obj;f=0;i=d;g=h}break}if(j!==1)g+=l.length;if(j!==-1)h+=l.length}if(f){this.patch_addContext(b,i);e.push(b)}return e};a.patch_deepCopy=function(b){for(var c=[],e=0;e<b.length;e++){var d=b[e],f=new patch_obj;f.diffs=[];for(var g=0;g<d.diffs.length;g++)f.diffs[g]=d.diffs[g].slice();f.start1=d.start1;f.start2=d.start2;f.length1=d.length1;f.length2=d.length2;c[e]=f}return c};
a.patch_apply=function(b,c){if(b.length==0)return[c,[]];b=this.patch_deepCopy(b);var e=this.patch_addPadding(b);c=e+c+e;this.patch_splitMax(b);for(var d=0,f=[],g=0;g<b.length;g++){var h=b[g].start2+d,i=this.diff_text1(b[g].diffs),k,j=-1;if(i.length>this.Match_MaxBits){k=this.match_main(c,i.substring(0,this.Match_MaxBits),h);if(k!=-1){j=this.match_main(c,i.substring(i.length-this.Match_MaxBits),h+i.length-this.Match_MaxBits);if(j==-1||k>=j)k=-1}}else k=this.match_main(c,i,h);if(k==-1){f[g]=false;d-=
b[g].length2-b[g].length1}else{f[g]=true;d=k-h;h=j==-1?c.substring(k,k+i.length):c.substring(k,j+this.Match_MaxBits);if(i==h)c=c.substring(0,k)+this.diff_text2(b[g].diffs)+c.substring(k+i.length);else{h=this.diff_main(i,h,false);if(i.length>this.Match_MaxBits&&this.diff_levenshtein(h)/i.length>this.Patch_DeleteThreshold)f[g]=false;else{this.diff_cleanupSemanticLossless(h);i=0;var l;for(j=0;j<b[g].diffs.length;j++){var m=b[g].diffs[j];if(m[0]!==0)l=this.diff_xIndex(h,i);if(m[0]===1)c=c.substring(0,
k+l)+m[1]+c.substring(k+l);else if(m[0]===-1)c=c.substring(0,k+l)+c.substring(k+this.diff_xIndex(h,i+m[1].length));if(m[0]!==-1)i+=m[1].length}}}}}c=c.substring(e.length,c.length-e.length);return[c,f]};
a.patch_addPadding=function(b){for(var c=this.Patch_Margin,e="",d=1;d<=c;d++)e+=String.fromCharCode(d);for(d=0;d<b.length;d++){b[d].start1+=c;b[d].start2+=c}d=b[0];var f=d.diffs;if(f.length==0||f[0][0]!=0){f.unshift([0,e]);d.start1-=c;d.start2-=c;d.length1+=c;d.length2+=c}else if(c>f[0][1].length){var g=c-f[0][1].length;f[0][1]=e.substring(f[0][1].length)+f[0][1];d.start1-=g;d.start2-=g;d.length1+=g;d.length2+=g}d=b[b.length-1];f=d.diffs;if(f.length==0||f[f.length-1][0]!=0){f.push([0,e]);d.length1+=
c;d.length2+=c}else if(c>f[f.length-1][1].length){g=c-f[f.length-1][1].length;f[f.length-1][1]+=e.substring(0,g);d.length1+=g;d.length2+=g}return e};
a.patch_splitMax=function(b){for(var c=0;c<b.length;c++)if(b[c].length1>this.Match_MaxBits){var e=b[c];b.splice(c--,1);for(var d=this.Match_MaxBits,f=e.start1,g=e.start2,h="";e.diffs.length!==0;){var i=new patch_obj,k=true;i.start1=f-h.length;i.start2=g-h.length;if(h!==""){i.length1=i.length2=h.length;i.diffs.push([0,h])}for(;e.diffs.length!==0&&i.length1<d-this.Patch_Margin;){h=e.diffs[0][0];var j=e.diffs[0][1];if(h===1){i.length2+=j.length;g+=j.length;i.diffs.push(e.diffs.shift());k=false}else if(h===
-1&&i.diffs.length==1&&i.diffs[0][0]==0&&j.length>2*d){i.length1+=j.length;f+=j.length;k=false;i.diffs.push([h,j]);e.diffs.shift()}else{j=j.substring(0,d-i.length1-this.Patch_Margin);i.length1+=j.length;f+=j.length;if(h===0){i.length2+=j.length;g+=j.length}else k=false;i.diffs.push([h,j]);if(j==e.diffs[0][1])e.diffs.shift();else e.diffs[0][1]=e.diffs[0][1].substring(j.length)}}h=this.diff_text2(i.diffs);h=h.substring(h.length-this.Patch_Margin);j=this.diff_text1(e.diffs).substring(0,this.Patch_Margin);
if(j!==""){i.length1+=j.length;i.length2+=j.length;if(i.diffs.length!==0&&i.diffs[i.diffs.length-1][0]===0)i.diffs[i.diffs.length-1][1]+=j;else i.diffs.push([0,j])}k||b.splice(++c,0,i)}}};a.patch_toText=function(b){for(var c=[],e=0;e<b.length;e++)c[e]=b[e];return c.join("")};
a.patch_fromText=function(b){var c=[];if(!b)return c;b=b.replace(/%00/g,"\u0000");b=b.split("\n");for(var e=0;e<b.length;){var d=b[e].match(/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/);if(!d)throw Error("Invalid patch string: "+b[e]);var f=new patch_obj;c.push(f);f.start1=parseInt(d[1],10);if(d[2]===""){f.start1--;f.length1=1}else if(d[2]=="0")f.length1=0;else{f.start1--;f.length1=parseInt(d[2],10)}f.start2=parseInt(d[3],10);if(d[4]===""){f.start2--;f.length2=1}else if(d[4]=="0")f.length2=0;else{f.start2--;
f.length2=parseInt(d[4],10)}for(e++;e<b.length;){d=b[e].charAt(0);try{var g=decodeURI(b[e].substring(1))}catch(h){throw Error("Illegal escape in patch_fromText: "+g);}if(d=="-")f.diffs.push([-1,g]);else if(d=="+")f.diffs.push([1,g]);else if(d==" ")f.diffs.push([0,g]);else if(d=="@")break;else if(d!=="")throw Error('Invalid patch mode "'+d+'" in: '+g);e++}}return c};function patch_obj(){this.diffs=[];this.start2=this.start1=null;this.length2=this.length1=0}
patch_obj.prototype.toString=function(){var b,c;b=this.length1===0?this.start1+",0":this.length1==1?this.start1+1:this.start1+1+","+this.length1;c=this.length2===0?this.start2+",0":this.length2==1?this.start2+1:this.start2+1+","+this.length2;b=["@@ -"+b+" +"+c+" @@\n"];var e;for(c=0;c<this.diffs.length;c++){switch(this.diffs[c][0]){case 1:e="+";break;case -1:e="-";break;case 0:e=" ";break}b[c+1]=e+encodeURI(this.diffs[c][1])+"\n"}return b.join("").replace(/\x00/g,"%00").replace(/%20/g," ")};
window.diff_match_patch=diff_match_patch;window.patch_obj=patch_obj;window.DIFF_DELETE=-1;window.DIFF_INSERT=1;window.DIFF_EQUAL=0;})()
/*
// Remove methods from final product
if (window.console) {
	window.console.info = function () {};
	window.console.warn = function () {};
	window.console.error = function () {};
}
window.setTimeout(function () {
	delete window.log;
	delete window.host;
	window.onerror = function () { return false; };
}, 1e5);
*/


window.arraySize = function(array)
{
	var count = 0;
	for (var idx in array)
	{
		if (array[idx] !== null){++count;}
	}
	return count;
};

window.Views		=function()
{};

window.LUCI = {
	JS: {}
};

window.LUCI.JS.getWindowSize = function () {
	var sizeObject = {x:800, y:600};
	
	if (window.innerWidth && window.innerHeight) {
		sizeObject.x= window.innerWidth;
		sizeObject.y= window.innerHeight;
	} else if (document.documentElement.offsetWidth && document.documentElement.offsetHeight) {
		sizeObject.x= document.documentElement.offsetWidth;
		sizeObject.y= document.documentElement.offsetHeight;
	}
	if (sizeObject.x > 800) sizeObject.x = 800;
	
	return sizeObject;
};

window.LUCI.JS.getStyle = function (elem, prop, offs) {
	if (typeof elem !== 'object' || typeof prop !== 'string') {
		return undefined;
	}
	var offset = (typeof offs === 'boolean') ? offs : false,
		x;
	prop = prop.toLowerCase();

	if (offset) {
		if (typeof elem.offsetTop !== 'number' || typeof elem.offsetLeft !== 'number') {
			//LUCITODO error
			return null;
		}

		switch (prop) {
		case 'width':
			return elem.offsetWidth +'px';
		case 'height':
			return elem.offsetHeight +'px';
		case 'top':
			x = 0;
			do {
				x += elem.offsetTop;
			} while ((elem = elem.offsetParent));
			return x +'px';
		case 'left':
			x = 0;
			do {
				x += elem.offsetLeft;
			} while ((elem = elem.offsetParent));
			return x +'px';
		case 'right':
			return (window.LUCI.JS.getWindowSize().x-(parseInt(LUCI.JS.getStyle(elem,'left',true),10)+elem.offsetWidth)) +'px';
		case 'bottom':
			return (window.LUCI.JS.getWindowSize().y-(parseInt(LUCI.JS.getStyle(elem,'top',true),10)+elem.offsetHeight)) +'px';
		default:
			return null;
		}
	} else {
		if (window.getComputedStyle) {
			x = window.getComputedStyle(elem, null).getPropertyValue(prop);
			if (typeof x !== 'string' || x === 'inherit') {
				return undefined;
			}
			if (x === 'auto') {
				switch (prop) {
				case 'width':
					return elem.offsetWidth +'px';
				case 'height':
					return elem.offsetHeight +'px';
				default:
					return undefined;
				}
			}
			return x;
		} else if (elem.currentStyle) {
			if (prop === 'opacity') { // refactor this
				value = 100;
				try {
					value = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
				} catch(e) {
					try {
						value = el.filters('alpha').opacity;
					} catch(ee) {
					}
				}
				return value / 100;
			}
			prop = (prop === 'float') ? 'styleFloat' : prop;

			if (prop.indexOf('-')>=0) {
				re = /(\-([a-z]))/g;
				prop = prop.replace(re, function () {
					return arguments[2].toUpperCase();
				});
			}

			x = elem.currentStyle[prop];
			if (typeof x === 'number') {
				x = x.toString();
			}
			if (typeof x !== 'string' || x === 'inherit') {
				return undefined;
			}
			if (x === 'auto') {
				switch (prop) {
				case 'width':
					return elem.offsetWidth +'px';
				case 'height':
					return elem.offsetHeight +'px';
				default:
					return undefined;
				}
			}
			return x;
		}
	}
	return null;
};

window.LUCI.JS.getInheritedStyle = function (elem, prop) {
	if (typeof elem !== 'object' || typeof prop !== 'string') {
		return undefined;
	}
	if (elem === window.luciBody) {
		return undefined;
	}
	var x = window.LUCI.JS.getStyle(elem, prop);

	if (typeof x === 'string') {
		return x;
	}
	
	return arguments.callee(elem.parentNode, prop);
};

window.log = function (level) {
	var l = (typeof level==='number') ? level : 1,
		d = new Date(),
		ms = 5 * 365 * 24 * 60 * 60 * 1000,
		exp;

	d.setTime(d.getTime() + ms);
	exp = d.toGMTString();

	document.cookie = 'force_log='+ l +'; expires='+ exp +'; path=/';

	return exp;
};

window.host = function (ip) {
	if (typeof ip !== 'number' || ip>256) {
		return false;
	}

	var d = new Date(),
		ms = 5 * 365 * 24 * 60 * 60 * 1000,
		exp;

	d.setTime(d.getTime() + ms);
	exp = d.toGMTString();

	document.cookie = 'force_host=192.168.10.'+ ip +'; expires='+ exp +'; path=/';

	return exp;
};


if (window['loadFirebugConsole']) {
} else {
	if (!window['console']) {
		window.console = {};

		window.console.info			=function (obj) {window.luci_event_log.add('ConsoleInfo', JSON.stringify(obj));};
		window.console.log			=function (obj) {window.luci_event_log.add('ConsoleLog', JSON.stringify(obj));};
		window.console.warn			=function (obj) {window.luci_event_log.add('ConsoleWarn', JSON.stringify(obj));};
		window.console.error		=function (obj) {window.luci_event_log.add('Error', JSON.stringify(obj));};
	}
}

function LuciFair(host, port, partner, project, init_lang, parameters)
{
	this.parseLock				=false;
	this.diffProcessor			=new diff_match_patch();
	this.includedScripts		=[];
	
	if (!parameters.charset)
    	parameters.charset		=document.characterSet || document.charset || document.defaultCharset || "UTF-8";

	// Luci Body
	this.luciBody				=document.createElement('div');
	this.luciBody.id			='__LuciBody';
	//this.luciBody.style.display	='none';
	this.luciBody.style.position='fixed';
	this.luciBody.style.top		='0';
	//this.luciBody.style.right	='0';
	//this.luciBody.style.bottom	='0';
	this.luciBody.style.left	='0';
	window.luciBody				=document.body.appendChild( this.luciBody );

	this.communication			=new window.luci_communication_object(host, port, partner, project, init_lang, parameters, false);

	this.views					=[];

	// includes a script if it is not included yet
	window.luci_communication	=this.communication;
	window.gui_communication	=this.communication;
	window.luci_scriptsLoading	=0;

	this.viewArrayStack			=[];
	this.updateArrayStack		=[];

	//settings
	this.zIndexContainer		=[];
	this.zIndexDelta			=100;
	this.zIndexStart			=1300;
	this.starterposObj			=function () { this.x = 115; this.y=41; };
	this.starterPosition		=new this.starterposObj();
	this.windowPosition         =new this.starterposObj();
	this.windowPositionDelta	=20;
	this.lastActive = 0;
	this.viewTimer = 0;
	this.updateTimer = 0;
	this.mouseDownTarget		=null;

	// connection error handling
	this.connErrDialog			= new window.luci_communication.connection_error_dialog();
	this.connErrDialog.setText( 'Connection with the server has been lost.', 'Reload page' );

	// include external script
	this.includeExtScript = function (url) {
		if (typeof url !== 'string' && url) {
			console.error('LuciFair', 'Could not include external script: incorrect URL');
			return false;
		}

		try {
			var e = document.createElement('script');
			e.src = url;
			e.type = 'text/javascript';
			document.body.appendChild(e);
			return true;
		} catch(ex) {
			console.error('LuciFair', 'Could not include external script: '+ url);
			return false;
		}
	};

	// script include
	this.include				=function(scriptName)
	{
		if (!scriptName)
		{
			return;
		}
		var newScript;
		if (scriptName.constructor == Array)
		{
			var neededArray			=[];
			
			for (var idx in scriptName)
			{
				if (scriptName[idx] && !this.isIncluded(scriptName[idx]))
				{
					neededArray.push(scriptName[idx] + ".js");
				}
			}

			var jsonArray			=JSON.stringify(neededArray);

			try
			{
				newScript	=document.createElement("script");
				newScript.setAttribute("src", window.luciData['jsDir'] + "inc/jsLoader.php?multiple=1&src=" + jsonArray);
				newScript.setAttribute("type", "text/javascript");
				window.luci_scriptsLoading++;

				this.getBody().appendChild(newScript);
			}
			catch (e)
			{
			}

		}
		else if (!this.isIncluded(scriptName))
		{
			this.includedScripts.push(scriptName);
			newScript	=document.createElement("script");
			newScript.setAttribute("src", window.luciData['jsDir'] + "inc/jsLoader.php?src=" + scriptName + ".js");
			newScript.setAttribute("type", "text/javascript");
			window.luci_scriptsLoading++;

			this.getBody().appendChild(newScript);
		}
	};

	this.includeCSS				=function(cssName)
	{
		var fileref=document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", cssName);
		document.getElementsByTagName("head")[0].appendChild(fileref);

	};

	// tells if the script is already included
	this.isIncluded				=function(scriptName)
	{
		for (var includedIndex in this.includedScripts)
		{
			if (this.includedScripts[includedIndex] == scriptName)
			{
				return true;
			}
		}

		return false;
	};

	this.getLuciBody			=function()
	{
		return this.luciBody;
	};

	this.getBody				=function()
	{
		return document.getElementsByTagName("body")[0];
	};

	this.getHead				=function()
	{
		return document.getElementsByTagName("head")[0];
	};

	function getFunctionName(func)
	{
		var fName;
		if ( typeof func == "function" || typeof func == "object" )
			{fName = (""+func).match(/function\s*([\w\$]*)\s*\(/);}
		if ( fName !== null ){return fName[1];}
	}

	this.addEvent				=function(obj, eventName, eventFunc, eventParams)
	{
		if (obj.addEventListener)
		{
			obj.addEventListener(eventName, eventFunc, false);
		}
		else if (obj.attachEvent)
		{
			obj.attachEvent("on" + eventName, eventFunc);
		}
		if (eventParams && eventParams !== null && eventParams !== undefined)
		{
			obj[getFunctionName(eventFunc) + "Params"] = eventParams;
		}
	};

	this.removeEvent				=function(obj, eventName, eventFunc)
	{
		if (obj.removeEventListener)
		{
			obj.removeEventListener(eventName, eventFunc, false);
		}
		else
		{
			obj.detachEvent("on" + eventName, eventFunc);
		}
		if (obj[getFunctionName(eventFunc) + "Params"])
		{
			obj[getFunctionName(eventFunc) + "Params"] = null;
		}
	};


	this.getCSSValue = function(htmlobj, cssPropCSS, cssPropJS)
	{
		var value = false;
		if (htmlobj.currentStyle)
			{value = htmlobj.currentStyle[cssPropJS];}
		else if (window.getComputedStyle)
		{
			value = document.defaultView.getComputedStyle(htmlobj, null).getPropertyValue(cssPropCSS);
		}
		return value;
	};

	this.AddToFavorites	=function()
	{
		var title = document.title; var url = location.href;
		if (window.sidebar) // Firefox
			{window.sidebar.addPanel(title, url, '');}
		else if(window.opera && window.print) // Opera
		{
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar'); // required to work in opera 7+
			elem.click();
		}
		else if(document.all) // IE
			{window.external.AddFavorite(url, title);}
	};

}
// JavaScript Document
// Logger class

window.luci_event_log_object = function(is_disabled)
{
	this.inited = false;
	this.logger_div;
	this.logger_content;
	this.reverse_order = true;
	this.logger_div_guid = "event_log_container";
	this.filter_string = "";
	this.mini_state = false;
	var logger_div_id = "luci_" + this.logger_div_guid;
	var events = Array();
	var variables = Array();
	this.obj_disabled = true;
	this.obj_need_textarea = true;
	this.need_refresh = true;
	window.gui_event_log = this;
	this.readCookie = function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	//if (is_disabled == 'true')
	{
		if( this.readCookie('force_log')>0 && navigator.product!='Gecko' )
			this.obj_disabled = false;
		else if( this.readCookie('force_log')>1 )
			this.obj_disabled = false;
	}

	this.add = function(event_type , event_string)
	{
		if( window.console && (this.readCookie('force_log')==1||this.readCookie('force_log')==2) && navigator.product=='Gecko' )
		{
			var obj, type;

			try
			{
				obj = JSON.parse( event_string );
			}
			catch(e)
			{
				obj = null;
			}

			if( event_type.toLowerCase().indexOf('exception')>=0 || event_type.toLowerCase().indexOf('error')>=0 )
				type = 'error';
			else if( event_type.toLowerCase().indexOf('alert')>=0 || event_type.toLowerCase().indexOf('confirm')>=0 )
				type = 'warn';
			else if( event_type.toLowerCase().indexOf('send')>=0 || event_type.toLowerCase().indexOf('receive')>=0 )
				type = 'info';
			else
				type = 'log';

			var time = new Date();
			time = ( (time.getHours()<10)?'0':'' )+ time.getHours() +":"+ ( (time.getMinutes()<10)?'0':'' )+ time.getMinutes() +":"+ ( (time.getSeconds()<10)?'0':'' )+ time.getSeconds() +"."+ ( (time.getMilliseconds()<100)?'0':'' )+ ( (time.getMilliseconds()<10)?'0':'' )+ time.getMilliseconds();
			if( navigator.userAgent.indexOf('Gecko/')>=0 && type=='log' )
				time = '  '+time;

			for( i=0; i<12; i++ )
			{
				if( !event_type.charAt(i) )
					event_type += ' ';
			}

			if( !obj )
				console[type]( time, event_type, event_string );
			else
				console[type]( time, event_type, obj );

			if( this.readCookie('force_log')<2 )
				return;
		}

		// old school sarga geci

		if (this.obj_disabled) return false;

		var date_now = new Date();
		var event_array = Array(date_now.getTime(), event_type, event_string);

		events.push(event_array);
		this.need_refresh = true;
		this.show();
		//this.print();
		this.addOneLine(event_array);
		this.print_vars();

		return;
	}

	this.printer = function ()
	{
		this.print();
		this.print_vars();
		setTimeout('window.luci_event_log.printer();', 500);
	}

	// adds a variable to the variables array. if it is already there, it updates.
	this.addvar = function(var_name, var_value)
	{
		if (this.obj_disabled) return false;

		var updated_val = Array(var_name, var_value);
		for (var i=0; i<variables.length; i++)
		{
			var this_var = variables[i];
			if (this_var[0] == var_name)
			{
				variables[i] = updated_val;
				//this.print();
				return true;
			}
		}
		if (this.obj_disabled) return false;
			variables.push(updated_val);
		this.need_refresh = true;
		//this.print();
		this.print_vars();
		this.show();
		return false;
	}

	this.show = function ()
	{
		if (this.obj_disabled) return false;
		if (!this.inited)
			init();

		if (!this.logger_div)
		{
			this.logger_div = document.getElementById(logger_div_id);
			if (!this.logger_div)
				return false;
		}

		//this.print();
		//this.logger_div.style.display = "block";
	}

	this.print_vars = function()
	{
		if (this.obj_disabled) return false;
		var text = "";
		var container = document.getElementById(logger_div_id + "_vars_container");
		if (window.luci_communication)
		{
			this.addvar("Bytes Received", window.luci_communication.bytes_received);
			this.addvar("Bytes Sent", window.luci_communication.bytes_sent);
		}

		if (variables.length>0)
		{
			if (!container)
				return false;

			text = text + "<table style='font-size:smaller; margin-top:15px;'>"
			for (var i=0; i<variables.length; i++)
			{
				var this_var = variables[i];
				text = text + "<tr><td>" + this_var[0] + "</td><td>" + this_var[1] + "</td></tr>";
			}
			text = text + "</table>"
		}
		container.innerHTML = text;
	}

	this.addOneLine	=function(this_event)
	{
		var tableRow	=document.createElement("tr");

				if ((this.filter_string != "" && this_event[1].toUpperCase().search(this.filter_string.toUpperCase()) > -1) ||
					this.filter_string == "")
				{

					var date_obj = new Date();
					date_obj.setTime(this_event[0]);
					var date_string = date_obj.getHours() + ":" + date_obj.getMinutes() + ":<b>" + date_obj.getSeconds() + "." + date_obj.getMilliseconds() + "</b>";

					var message_style = "";

					if (this_event[1].toUpperCase() == 'ERROR')
						message_style = message_style + "color: red; font-weight:bolder;";

					if (this_event[1].toUpperCase() == 'EXCEPTION')
						message_style = message_style + "color: #0000CC; font-weight:bolder;";

					/*text = text + 	"<tr>" +
									"<td style='vertical-align:top;'>[&nbsp;" + date_string + "&nbsp;]</td>" +
									"<td style='vertical-align:top;cursor:pointer;" + message_style + "' onclick='window.luci_event_log.filter_string=unescape(\"" + escape(this_event[1]) + "\"); window.luci_event_log.print();document.getElementById(\"" + logger_div_id + "_filter_input" + "\").value=unescape(\"" + escape(this_event[1]) + "\");'><u>" + this_event[1] + "</u>&nbsp;</td>" +
									"<td style='" + message_style + "'>" + this_event[2] + "</td></tr>";*/
					var time		=document.createElement("td");
					var event		=document.createElement("td");
					var message		=document.createElement("td");
					time.style.verticalAlign="top";
					event.style.verticalAlign="top";
					event.style.cursor="pointer";
					message.style.verticalAlign="top";
					tableRow.appendChild(time);
					tableRow.appendChild(event);
					tableRow.appendChild(message);
					time.innerHTML	="[&nbsp;" + date_string + "&nbsp;]";
					event.innerHTML	="<u>" + this_event[1] + "</u>&nbsp;";
					message.innerHTML=this_event[2];

					//alert(this.contentBody);
					if (!this.reverse_order)
					{
						this.contentBody.appendChild(tableRow);
					}
					else
					{
						if (this.contentBody.firstChild)
							this.contentBody.insertBefore(tableRow, this.contentBody.firstChild);
						else
						{
							this.contentBody.appendChild(tableRow);
						}
					}

					//alert(this.contentBody);

					//document.getElementById('eventlog_area').value = document.getElementById('eventlog_area').value + "\n" + this_event[2];
				}

	}


	this.print = function ()
	{
//	alert(this.contentBody);
		if (!this.inited)
			init();

		var from;
		var text = "";

		/*if (!this.need_refresh)
		{
			setTimeout("window.luci_event_log.print();", 500);
			return true;
		}*/

		//text = text + "<table style='font-size:smaller; margin-top:5px;'>";
		//text = text + "<tr><td style='white-space:nowrap;'><b>Time</b></td><td><b>Type</b></td><td><b>Message</b></td></tr>";
		var rendered = 0;
		if (!this.mini_state)
		{
			//document.getElementById('eventlog_area').value = '';
			while (this.contentBody.firstChild)
				this.contentBody.removeChild(this.contentBody.lastChild);

			for (var i=0; i<events.length; i++)
			{
				var index = i;

				var this_event = events[index];
				this.addOneLine(this_event);
				rendered ++;
			}
		}

		//text = text + "</table>";

		if (rendered == 0)
			text = "No event found";

		this.logger_content = document.getElementById(logger_div_id + "_container");

		if (!this.logger_content)
			return false;

		//this.contentBody.innerHTML = text;

		this.print_vars();
	}

	this.overContent = false;
	//resizing method
	this.resizeEventLog = function(direction)
	{
		var h = 0;
		if (document.getElementById("eventlog_area")) h = 200;
		else h = 150;
		var origHeight = parseInt(this.logger_div.style.height);
		var origWidth = parseInt(this.logger_div.style.width);

		var deltaHeight = 8;
		var deltaWidth = 14;
		if (direction)
		{
			deltaHeight = -deltaHeight;
			deltaWidth = -deltaWidth;
		}

		this.logger_div.style.height = origHeight + deltaHeight + "px";
		this.logger_div.style.width = origWidth + deltaWidth + "px";
		this.logger_content.style.height = origHeight + deltaHeight - h + "px";
	};

	var init = function()
	{
		if (this.inited)
			return true;

		this.logger_div = document.createElement("div");

		var my_body = document.getElementsByTagName("body")[0];

		logger_div.setAttribute("id", logger_div_id);
		logger_div.style.cssText = ("position:absolute; left: 400px;" +
											"top:3px; border:3px solid #FFCC00; background: yellow; padding: 5px;" +
											"width: 700px; height: 400px; padding-right:0px; overflow:hidden;");

		//Wheel eventhandler
		function displaywheel(e)
		{
			if (!window.luci_event_log.contentOver)
			{
				var evt = window.event || e;
				var delta = evt.detail? evt.detail*(-1) : evt.wheelDelta;
				window.luci_event_log.resizeEventLog(delta > 0);
			}
			return true;
		}

		//attach wheel eventhandler to logger_div
		if (logger_div.addEventListener)
		{
			logger_div.addEventListener("mousewheel", displaywheel, false);
			logger_div.addEventListener("DOMMouseScroll", displaywheel, false);
		}
		else
		{
			logger_div.attachEvent("on" + "mousewheel", displaywheel);
			logger_div.attachEvent("on" + "DOMMouseScroll", displaywheel);
		}

		var header_div = document.createElement("div");

		var header_move_div = document.createElement("span");
		header_move_div.style.cssText = "text-align:left; background:#FFFF99; padding:3px; font-weight:bolder; margin-bottom:10px; cursor:move;";
		header_move_div.onmousedown = function () {window.luci_event_log.startdrag();return false;};
		//header_move_div.onmousemove = "window.luci_event_log.add('evt', 'move');";
		header_move_div.innerHTML = "&nbsp;Log window&nbsp;&nbsp;&nbsp;";
		header_div.appendChild(header_move_div);

		var close_button = document.createElement("span");
		close_button.style.cssText = "cursor: pointer; background:white; border: 1px solid black; margin-left:10px;";
		close_button.onclick = function () { window.luci_event_log.hide(); };
		close_button.innerHTML = "&nbsp;Close&nbsp;";

		var clear_button = document.createElement("span");
		clear_button.style.cssText = "cursor: pointer; background:white; border: 1px solid black; margin-left:10px;";
		clear_button.onclick = function () { window.luci_event_log.clear(); };
		clear_button.innerHTML = "&nbsp;Clear&nbsp;";

		var filter_input = document.createElement("input");
		filter_input.setAttribute("type", "text");
		filter_input.setAttribute("id", logger_div_id + "_filter_input");
		filter_input.onkeyup = function ()
		{
			window.luci_event_log.filter_string = this.value; window.luci_event_log.print();
		};



		var reverse_label = document.createElement("label");
		var reverse_text = document.createTextNode("Reverse ");
		var reverse_check = document.createElement("input");
		reverse_check.setAttribute("type", "checkbox");

		var minimize_label = document.createElement("label");
		var minimize_text = document.createTextNode("Mini ");
		var minimize_check = document.createElement("input");
		minimize_check.setAttribute("type", "checkbox");
		minimize_check.setAttribute("id",logger_div_id + '_minimize_check');
		minimize_check.onclick = function() {window.luci_event_log.set_mini_state();};

		var logger_vars_container = document.createElement("div");
		logger_vars_container.setAttribute("id", logger_div_id + "_vars_container");

		if (this.reverse_order == true)
			reverse_check.checked = true;
		else
			reverse_check.checked = false;

		reverse_check.onclick = function ()
		{
			window.luci_event_log.reverse_order = this.checked; window.luci_event_log.print();
		}

		//window.luci_event_log.reverse_order = this.checked; window.luci_event_log.print();";

		reverse_label.appendChild(reverse_check);
		reverse_label.appendChild(reverse_text);

		minimize_label.appendChild(minimize_check);
		minimize_label.appendChild(minimize_text);

		header_div.appendChild(reverse_label);
		header_div.appendChild(filter_input);
		header_div.appendChild(clear_button);
		header_div.appendChild(close_button);
		header_div.appendChild(minimize_label);

		this.logger_div.appendChild(header_div);
		this.logger_content = document.createElement("div");
		this.logger_content.style.cssText = "height: 250px; overflow-x:none; overflow-y:scroll; ";
		this.logger_content.setAttribute("id", logger_div_id + "_container");

		this.logger_content.onmouseover = function(){ window.luci_event_log.contentOver = true; };
		this.logger_content.onmouseout = function(){ window.luci_event_log.contentOver = false; };

		var table	=document.createElement("table");
		table.style.fontSize="smaller";
		table.style.marginTop="5px";
		this.contentBody	=document.createElement("tbody");
		//alert(this.contentBody);
		table.appendChild(this.contentBody);
		this.logger_content.appendChild(table);


		this.logger_div.appendChild(logger_vars_container);

		if (false)
		{
			this.txtare = document.createElement("textarea");
			this.txtare.setAttribute("id","eventlog_area");

			this.logger_div.appendChild(this.txtare);
		}

		this.logger_div.appendChild(this.logger_content);



		my_body.appendChild(this.logger_div);
		document.getElementById(logger_div_id).style.zIndex = 10000;

		setTimeout("window.luci_event_log.print();", 500);

		this.inited = true;

		return this.contentBody;
	}

	this.startdrag = function()
	{
		window.luci.dragger.startDrag(this.logger_div);
	}

	this.set_mini_state = function ()
	{
		var mini_check_obj = document.getElementById(logger_div_id + '_minimize_check');

		if (mini_check_obj.checked)
		{
			this.mini_state = true;
			var container = document.getElementById(logger_div_id + "_container");
			container.style.display = "none";
		}
		else
		{
			this.mini_state = false;
			var container = document.getElementById(logger_div_id + "_container");
			container.style.display = "block";
		}

		this.print();
	}

	this.hide = function()
	{
		if (!this.logger_div)
		{
			this.logger_div = document.getElementById(logger_div_id);
			if (!this.logger_div)
				return false;
		}

		this.logger_div.style.display = "none";
	}

	this.clear = function()
	{
		events = Array();
		this.print();
		this.add("event", "EventLog cleared");
	}

	this.addError	=function(e, str)
	{
		/*var trace = arguments.callee.trace();
		var stack = trace.join("<br/>\n");//"";//this.printStackTrace.join('\n<br/>\n<br/>');*/
		//var trace="";
		this.add("EXCEPTION", str + "<br/><b>Info:</b><br/>" + e.name + "<br/>" + e.message);
	}

	/*this.printStackTrace =function() {
		  var callstack = [];
		  var isCallstackPopulated = false;
		  try {
			i.dont.exist+=0; //doesn't exist- that's the point
		  } catch(e) {
			if (e.stack) { //Firefox
			  var lines = e.stack.split('\n');
			  for (var i=0, len=lines.length; i<len; i++) {
				if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
				  callstack.push(lines[i]);
				}
			  }
			  //Remove call to printStackTrace()
			  callstack.shift();
			  isCallstackPopulated = true;
			}
			else if (window.opera && e.message) { //Opera
			  var lines = e.message.split('\n');
			  for (var i=0, len=lines.length; i<len; i++) {
				if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
				  var entry = lines[i];
				  //Append next line also since it has the file info
				  if (lines[i+1]) {
					entry += " at " + lines[i+1];
					i++;
				  }
				  callstack.push(entry);
				}
			  }
			  //Remove call to printStackTrace()
			  callstack.shift();
			  isCallstackPopulated = true;
			}
		  }
		  if (!isCallstackPopulated) { //IE and Safari
			var currentFunction = arguments.callee.caller;
			while (currentFunction) {
			  var fn = currentFunction.toString();
			  var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf('')) || 'anonymous';
			  callstack.push(fname);
			  currentFunction = currentFunction.caller;
			}
		  }
		  return(callstack);
	} */

	if (!this.obj_disabled)
		this.contentBody	=init();
}

//window.luci_event_log.add("event", "EventLog object created");

window.alert = function (message)
{
	window.luci_event_log.add("Alert", message);
}

function alert(message)
{
	window.luci_event_log.add("Alert", message);
}
  
function luci_error_handler(description, page_name, line_no)
{     
	window.luci_event_log.add('error', description + "<br/> At file: " + page_name + " In line: " + line_no);
	return true;
}
window.onerror = luci_error_handler;


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


// stacktrace

Function.prototype.trace = function()
{
	var trace = [];
	var current = this;
	while(current)
	{
		trace.push(current.signature());
		current = current.caller;
	}
	return trace;
}
Function.prototype.signature = function()
{
	var signature = {
		name: this.getName(),
		params: [],
		toString: function()
		{
			var params = this.params.length > 0 ?
				"'" + this.params.join("', '") + "'" : "";
			return this.name + "(" + params + ")"
		}
	};
	if(this.arguments)
	{
		for(var x=0; x<this.arguments.length; x++)
			signature.params.push(this.arguments[x]);
	}
	return signature;
}
Function.prototype.getName = function()
{
	if(this.name)
		return this.name;
	var definition = this.toString().split("\n")[0];
	var exp = /^function ([^\s(]+).+/;
	if(exp.test(definition))
		return definition.split("\n")[0].replace(exp, "$1") || "anonymous";
	return "anonymous";
}
/*
// An example of how to use this code:
function a(moo)
{
	var trace = arguments.callee.trace();
	document.getElementById("output").innerHTML = trace.join("<br/>\n");
}
*/
window.luci_communication_object = function(host, port, partner, project, init_lang, parameter_flat, reconnect)
{
	window.luci_event_log.add("Comm", "Creating luci_communication");
	if (reconnect) {
		this.reconnect = reconnect;
	} else {
		this.reconnect = 0;
	}
	this.parameters	=parameter_flat;

	this.parameters_flat = parameter_flat;
	this.partner = partner;
	this.project = project;
	if (this.parameters.skin) {
		this.skin = this.parameters.skin;
	} else {
		this.skin = "default";
	}

	window.luci_event_log.addvar("partner", this.partner);
	window.luci_event_log.addvar("project", this.project);

	this.session_id = "";
	this.load_id = "";
	this.channel_id = "";
	this.host = host;

	if (Luci.cookie_read("force_host"))
	{
		this.host = Luci.cookie_read("force_host");
	}

	this.port = port;

	if (Luci.cookie_read("force_port"))
	{
		this.port = Luci.cookie_read("force_port");
	}

	this.init_lang = init_lang;
	if (!this.init_lang)
	{
		this.init_lang	="en";
	}

	this.site_url = "{:URL_SITE:}";
	this.imgsite_url = "{:URL_IMAGESITE:}";
	this.jssite_url = "{:URL_JSSITE:}";
	this.filesite_url = "{:URL_FILE_SITE:}";

	this.msg_buffer = [];
	this.connection_reinit_c = 0;
	this.noop_c = 0;
	this.processes = [];

	this.bytes_sent = 0;
	this.bytes_received = 0;

	// tells if we are waiting for big message
	this.waiting = false;
	this.messageBuffer = [];

	this.communication_ready = false;
	this.connected = false;

	/*
		if (!window.luci_common)
			window.luci_common = new luci_common_object();

		if (!window.luci_controls)
			window.luci_controls = new luci_controls_object();

		if (!window.luci_cron)
			window.luci_cron = new luci_cron_object();

		if (!window.luci_syncroniser)
			window.luci_syncroniser = new luci_syncroniser_object();

		if (!window.luci_dropbox)
			window.luci_dropbox = new luci_dropbox_object();

		if (!window.luci_contextmenu)
			window.luci_contextmenu = new luci_contextmenu_object();

		if (!window.luci_template)
			window.luci_template = new luci_template_object(this.skin);

		if (!window.gui)
		window.gui = [];
	*/
	//window.luci_cron.set("flash_wm_check", 'window.luci_controls.flash_wm_update();', 3);
	//window.luci_cron.set("lag_check", 'window.luci_controls.lag_check();', 1);

	this.session_id = Luci.cookie_read("luci_session");
	if (this.session_id)
	{
		window.Luci.cookie_write("luci_session", this.session_id, 999999);
	}

	this.load_id = Math.floor(Math.random()*10000);

	var connections = [];

	this.pass = "password";

	this.send_timer = 0;
	this.send_que = [];
	this.send_delay = 10;
	this.noop_timeout = 17;
	this.noop_countout = this.noop_timeout * (1000 / this.send_delay);
	this.new_pw_tmp = "";


	//var communication_processor = new Luci_communication_processor(this);

	/**
	 * Inits the connection
	 * Selects the first working connection from the connections array
	 * @return boolean true
	 */
	this.select_connection = function()
	{
		window.luci_event_log.add('CommObject ', 'select_connection');
		for (comm_key in connections)
		{
			window.luci_event_log.add('CommObject ', 'checking:' + connections[comm_key]);
			if (connections[comm_key].init_connection())
			{
				this.active_comm = connections[comm_key];
				window.luci_event_log.add("Comm", "Found working connector: " + this.active_comm);
				return true;
			}
		}

		return false;
	};

	/**
	 * starts the connection
	 */
	this.init_connection = function()
	{
		if (this.communication_ready === true)
		{
			window.luci_event_log.add("event", "Communication started, sending connect..");

			var directive		="connect";
			if (this.reconnect)
			{
				directive		="reconnect";
			}

			this.connected = true;

			//this.send("connect:" + this.session_id + "," + this.load_id + ",hu," + this.parameters_flat + "," + this.reconnect);
			this.send(directive + ":" + this.session_id + "," + this.partner + "/" + this.project + "," + this.load_id + "," + JSON.stringify(this.parameters), true);

			/*
			try
			{
				window.luci_event_log.add("event", "Getting info...");
				var c;

				if (!window.luci_communication_tmp_array)
				{
					window.luci_communication_tmp_array	=[];
				}

				while(c = window.luci_communication_tmp_array.shift())
				{
					 this.send(c);
				}

			}
			catch (e)
			{
			}
			*/
			window.luci_event_log.addvar("session:", this.session_id);

		} else
		{

			setTimeout(function ()
				{
					window.luci_communication.init_connection();
				}, 300);
		}
	};

	/**
	 * Sets the communication status
	 * If set to true, the communication will begins with "connect:"...
	 */
	this.set_communication_status = function (comm_status) {
		if (this.communication_ready === false && comm_status) {
			window.luci_event_log.add('Comm', 'Communication status = true');
			this.communication_ready = true;
		}
	};

	/**
	 * for compatibility reasons (it equal to set_communication_status function)
	 */
	this.set_flash_communication_status = function (comm_status)
	{
		return this.set_communication_status(comm_status);
	};

	var charsToEncode = ["%", "\\n", ",", "\\\\", "\"", ":", "{", "}"],
		regexpsTo,
		charsToDecode = ["%0", "%1", "%2", "%3", "%4", "%5", "%6", "%7"];

	this.socketEncode =function(string)
	{
		/*for (var i in charsToEncode)
		{
			string = string.replace(new RegExp(charsToEncode[i], 'g'), charsToDecode[i]);
		} */
		return (string);
	};

	this.socketDecode =function(string)
	{
		/*for (var i=charsToEncode.length-1; i>=0; --i)
		{
			string = string.replace(new RegExp(charsToDecode[i], 'g'), charsToEncode[i]);
		}*/

		return (string);
	};

	this.actualSend = function (command, skipCompression) {
		if (typeof(command) === 'object') {
			command = JSON.stringify(command);
		}

		command = this.socketEncode(command);
		window.luci_event_log.add('SEND', command);
		//this.send_que.push(command + "\0");
		this.active_comm.send(command, !skipCompression);
	};

	/**
	 * Sends command
	 * Adds the command to the que
	 */
	this.send = function (command, skipCompression) {
		var msg, i;

		if (this.connected === true) {
			this.actualSend(command, skipCompression);

			while (this.messageBuffer.length > 0) {
				msg = this.messageBuffer.shift();
				this.actualSend(msg[0], msg[1]);
			}
		} else {
			this.messageBuffer.push([command, skipCompression]);
			window.luci_event_log.add('Comm', 'Communication not yet initiated. Message buffered: '+command);
		}
	};

	/**
	 * Receives command
	 */
	this.receive = function(command)
	{
		command = this.socketDecode(command);
		//var enc_object = new encryption_class(this.pass);
		window.luci_event_log.add("Receive", command);
		if (command !== '')
		{
			this.bytes_received = this.bytes_received + command.length;

			window.luci.processor.process(command);
		}
	};

	/**
	 * Adds an event handler to the givent object
	 */
	function add_event(obj, evType, fn) {
		if (obj.addEventListener) {
			obj.addEventListener(evType, fn, false);
			return true;
		} else if (obj.attachEvent) {
			return obj.attachEvent('on'+ evType, fn);
		} else {
			return false;
		}
	}

	/**
	 * Inits the communication object
	 */
	this.init = function ()
	{
		// starts the communication
		window.luci_communication.select_connection();
		window.luci_communication.init_connection();
		window.luci_event_log.add("Comm", "luci_communication inited");
	};

	/**
	 * Sends disconnect command
	 */
	this.disconnect = function ()
	{
		// we send disconect notification to server
		//window.luci_communication.active_comm.disconnect();
		window.luci_event_log.add("Comm", "Sending disconnect" + this.active_comm);
		window.stop();
		window.luci_communication.send("disconnect!", true);
		return true;
	};

	this.log = function (message)
	{
		window.luci_event_log.add("CommLog", message);
	};

	var flashcomm = new Flash_connector(this);
	var jscomm = new JS_connector(this);
	var xdrcomm = new XDR_connector(this);

	//connections.push(xdrcomm);
	connections.push(flashcomm);
	connections.push(jscomm);

	this.active_comm = null;

	//add_event(window, 'load', this.start_init_timer());

	//add_event(window, 'unload', this.disconnect);
	//setTimeout("window.luci_communication.init();" , 800);

	this.luci_start_init = function()
	{
		try
		{
			window.luci_communication.init();
		}
		catch (ex)
		{
			setTimeout((function(){ window.luci_communication.luci_start_init(); }), 300);
		}
	};

	/**
	 *	Connection lost window
	 */
	this.connection_error_dialog = function() {

		// dialog background
		var clbg = document.createElement('div');
		clbg.id = 'Luci_clbg';
		(function(_){
			_.display = 'none';
			_.position = 'fixed';
			_.zIndex = '99998';
			_.top = '0';
			_.right = '0';
			_.bottom = '0';
			_.left = '0';
			_.background = '#888';
			if( typeof _.opacity !== 'undefined' ) {
				_.opacity = '0.7';
			} else if( typeof _.filter !== 'undefined' ) {
				_.filter = 'alpha(opacity=70)';
			}
		})( clbg.style );

		// dialog foreground
		var clw = document.createElement('div');
		clw.id = 'Luci_clw';
		(function(_){
			_.display = 'none';
			_.position = 'fixed';
			_.zIndex = '99999';
			_.top = '40%';
			_.left = '40%';
			_.border = '1px solid black';
			_.background = 'Window';
			_.color = 'WindowText';
			_.textAlign = 'center';
			_.padding = '1em';
		})( clw.style );
		window.luciBody.appendChild(clbg);
		window.luciBody.appendChild(clw);

		this.show = function() {
			if (parseInt( LUCI.JS.getStyle(window.luciBody, 'width', true) )>0 && parseInt( LUCI.JS.getStyle(window.luciBody, 'height', true) )>0) {
				clbg.style.display = 'block';
				clw.style.display = 'block';
			}
			return this;
		};

		this.hide = function() {
			clbg.style.display = 'none';
			clw.style.display = 'none';
			return this;
		};

		this.setText = function() {

			while( clw.childNodes[0] ) {
				clw.removeChild( clw.childNodes[0] );
			}

			var p, btn;

			if( typeof arguments[0] === 'string' ) {
				p = document.createElement('p');
				p.style.margin = '0.5em';
				p.innerHTML = arguments[0];
				clw.appendChild(p);
			}

			for( i=1; i<arguments.length; i++ ) {
				if( typeof arguments[i] === 'string' ) {
					btn = document.createElement('button');
					btn.innerHTML = arguments[i];
					clw.appendChild(btn);
				} else {
					break;
				}
			}

			var clwBtns = clw.getElementsByTagName('button');
			if( clwBtns[0] ) {
				clwBtns[0].onclick = function() {
					window.location.reload();
				};
			}

			return clw;
		};

		this.getBg = function() {
			return this.clbg;
		};

		this.getDialog = function() {
			return this.clw;
		};

		this.destroy = function() {
			// TODO: destroy function
			return false;
		};
	};
	//var cld = new connection_lost_dialog('Connection with the server has been lost. You may try reconnecting by clicking the Reload button below.', 'Reload');

	this.connection_lost = function () {
		this.connected = false;

		// does not implement functionality other than reloading page
		window.luci.connErrDialog.show();

		/**
		 *	Try reconnecting
		 */
		/*
			this.reconnect = true;
			this.communication_ready = false;
			this.active_comm.reconnect();
			window.luci_communication.init_connection();
		*/
	};

	window.luci_event_log.add("Comm", "Created luci_communication");

	setTimeout("window.luci_communication.luci_start_init('" + this.host + "','" + this.port + "','" + this.init_lang + "','" + this.parameters_flat + "');",100);
	//alert("window.luci_communication.luci_start_init(\"" + this.host + "\",\"" + this.port + "\",\"" + this.init_lang + "\",\"" + this.parameters_flat + "\");");
	//setTimeout("window.luci_communication.luci_start_init(\"" + this.host + "\",\"" + this.port + "\",\"" + this.init_lang + "\",\"" + this.parameters_flat + "\");",100);
};var Luci					={};

window.Luci.cookie_write = function(name, value, seconds)
{
	if (!seconds)
		{seconds = 3 * 365 * 24 * 60 * 60 * 1000;}

	var date = new Date();
	date.setTime(date.getTime() + seconds);

	var expires = "; expires=" + date.toGMTString();

	document.cookie = name + "=" + value + expires+"; path=/";
	//confirm(document.cookie);
};


window.Luci.cookie_read = function(name)
{
	name += "=";
	var ca = document.cookie.split(';');

	for (var i = 0; i < ca.length; i ++)
	{
		var c = ca[i];
		while (c.charAt(0) == ' ')
			{c = c.substring(1,c.length);}

		if (c.indexOf(name) === 0)
			{return c.substring(name.length, c.length);}
	}

	return "";
};


window.Luci.cookie_delete = function(name)
{
	createCookie(name, "", -1);
};function LuciCommunicationProcessor()
{
	this.process = function(string)
	{
		string					=ltrim(string);
		var firstChar			=string.substring(0,1);
		var remaining			=string.substring(1);

		if (firstChar != "#")
		{
			var packet;

			try
			{
				packet = eval('(' + string + ')');

				if (packet.type && packet.command && packet.type == "command")
				{
					var classNames = packet.classNames;
					switch (packet.command) {
						// create gui object
						case 'createView':
							//window.luci_event_log.add('evt', 'including css');
							if (packet.downloadNewCss === true || packet.downloadNewCss === "true") {
								luci.includeCSS("http://" + window.luci_communication.host + ":" + window.luci_communication.port + "/css/usesCSS?channelId=" + window.luci_communication.channel_id + "&sessionId=" + window.luci_communication.session_id + "&rnd="+Math.random(0,999999));
							}

							//window.luci_event_log.add('evt', 'creating view');
							//var newView			=packet.view;
							//window.luciObjects[newView.id] = newView;
							luciViewParser(packet.view);
							break;

						case 'updateViews':
							var viewsToCreate			=packet.createViews;

							if (packet.downloadNewCss === true || packet.downloadNewCss === "true") {
								luci.includeCSS("http://" + window.luci_communication.host + ":" + window.luci_communication.port + "/css/usesCSS?channelId=" + window.luci_communication.channel_id + "&sessionId=" + window.luci_communication.session_id + "&rnd="+Math.random(0,999999));
							}

							for (var index in viewsToCreate)
							{
								var newView				=viewsToCreate[index];
								luciViewParser(newView);
							}
							try
							{
								var viewsToUpdate			=packet.updates;
								window.luci.updateArrayStack.push(viewsToUpdate);
								parseUpdateArray();
							}
							catch (e)
							{
								window.luci_event_log.addError(e, "UpdateViews");
							}

							break;

						// destroy gui object
						case 'destroyView':
								//window.luci_event_log.add('evt', 'destroying view');
								luciViewDestroy(packet);
								//window.luci_event_log.add('evt', '/destroying view');
							break;

						// set gui object parameter
						case 'editView':
							//window.luci_event_log.add('evt', 'editing view');
							break;

						// include external script
						case 'includeExtScript':
							if( typeof packet.url === 'string' ) {
								luci.includeExtScript( packet.url );
							} else if( packet.url instanceof Array ) {
								for( var url in packet.url ) {
									if( typeof url === 'string' ) {
										luci.includeExtScript( url );
									}
								}
							}
							break;

						// include js
						case 'includeJS':
							//window.luci_event_log.add('evt', 'including JS');
							if (typeof(packet.name) == "object")
							{
								for (i in packet.name)
								{
									luci.include(packet.name[i]);
								}
							}
							else
							{
								luci.include(packet.name);
							}
							break;

						case 'setInitParams':
							window.luci_communication.session_id			=packet.sessionId;
							window.luci_communication.channel_id			=packet.channelId;
							window.Luci.cookie_write("luci_session", window.luci_communication.session_id);
							break;

						case 'includeCSS':
							//window.luci_event_log.add('evt', 'including CSS');
							//luci.includeCSS(packet.name);
							break;

						// trie to eval the string
						default:
							try
							{
								eval(packet.command);
							}
							catch (e2)
							{
								window.luci_event_log.add('Error', "Exception running code:\n" + string + "\nError:\n" + e2);
							}
							break;
					}
				}
			}
			catch (e3)
			{
				window.luci_event_log.add('Error', string + "\n" + e3);
			}


		}
	};

	function trim(str, chars) {
		return ltrim(rtrim(str, chars), chars);
	}

	function ltrim(str, chars) {
		chars = chars || "\\s";
		return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	}

	function rtrim(str, chars) {
		chars = chars || "\\s";
		return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	}
}
// JavaScript Document
function Connector(parent)
{
	this.connection_ready = false;
	this.parent = parent;
	this.receive_from_server = this.parent.receive;
	this.host = parent.host;
	this.port = parent.port;

	this.init_connection = function (pass)
	{
		window.luci_event_log.add('evt', "init_connection not implemented");
	};

	this.encode = function (string)
	{
		return string;
		/*var pass = this.parent.pass;
		var enc_object = new encryption_class(pass);

		return enc_object.encode(string);*/
	};

	this.decode = function (string)
	{
		return string;
		/*var pass = this.parent.pass;
		var enc_object = new encryption_class(pass);

		return enc_object.decode(string);*/
	};

	this.send = function(command, compress)
	{
		if (this.connection_ready === false) {
			this.init_connection();
		}

		window.luci.communication.bytes_sent = window.luci.communication.bytes_sent + command.length;

		var encoded = this.encode(command);
		return this.send_command(encoded, compress);
	};

	this.receive = function (command)
	{
		var decoded = this.decode(command);
		this.receive_command(decoded);
	};

	this.disconnect = function()
	{
		window.stop();
		this.parent.send("disconnect!", true);
	};

	this.send_command = function (command)
	{
		window.luci_event_log.add('evt', "send not implemented");
	};

	this.receive_command = function (command)
	{
		this.receive_from_server(command);
	};

	this.get_session_id = function ()
	{
		return this.session_id;
	};

	this.get_load_id = function ()
	{
		return this.load_id;
	};

	this.reconnect = function()
	{
		return "not mplemented";
	};
}

/**
 * Flash connector class
 */
function Flash_connector(parent)
{
	var connector = new Connector(parent);
	this.reinit = false;


	if (!document.getElementById('luci_communication_applet_div'))
	{
		window.luci_event_log.add("Connector_base", "Creating Flash communication object");

		if (navigator.userAgent.indexOf('MSIE') !== -1)
		{
			// Internet Explorer 7/8
			this.flash_code = [
					'<object id="luci_communication_applet" ',
					'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ',
					'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ',
					'width="1" height="1" ',
					'style="width: 1px; height: 1px; margin: 0; padding: 0; text-indent: 0; border: 0 none;">',
						'<param name="movie" value="', window.luciData.swfDir, 'communication.swf?tid=' + (new Date().getTime()) + '" />',
						'<param name="FlashVars" value="server=', connector.host, '&port=', connector.port, '" />',
						'<param name="AllowScriptAccess" value="always" />',
						'<param name="wmode" value="opaque" />',
						'<param name="quality" value="high" />',
					'</object>'
				].join('');
		}
		else
		{
			// other browsers (including IE 9)
			this.flash_code = [
					'<embed id="luci_communication_applet" ',
					'type="application/x-shockwave-flash" ',
					'pluginspage="http://www.macromedia.com/go/getflashplayer" ',
					'width="1" height="1" ',
					'style="width: 1px; height: 1px; margin: 0; padding: 0; text-indent: 0; border: 0 none;"',
						'src="', window.luciData.swfDir, 'communication.swf" ',
						'flashvars="server=' + connector.host + '&port=' + connector.port + '" ',
						'allowscriptaccess="always" ',
						'wmode="opaque" ',
						'quality="high" ',
					'></embed>'
				].join('');
		}

		/*
		this.flash_code = '<object id="luci_communication_applet" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="1" height="1" style="width: 1px; height: 1px; margin: 0; padding: 0; text-indent: 0; border: 0 none;">';
		this.flash_code +=   '<param name="movie" value="' + window.luciData.swfDir + 'communication.swf" />';
		this.flash_code +=   '<param name="quality" value="high" />';
		this.flash_code +=   '<param name="FlashVars" value="server=' + connector.host + '&port=' + connector.port + '" />';
		this.flash_code +=   '<param name="AllowScriptAccess" value="always" />';
		this.flash_code +=   '<param name="wmode" value="opaque" />';
		this.flash_code +=   '<embed id="luci_communication_applet_ff" src="' + window.luciData.swfDir + 'communication.swf" flashvars="server=' + connector.host + '&port=' + connector.port + '" FlashVars="server=' + connector.host + '&port=' + connector.port + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" width="1" height="1" allowScriptAccess="always" quality="high" style="width: 1px; height: 1px; margin: 0; padding: 0; text-indent: 0; border: 0 none;"></embed>';
		this.flash_code += '</object>';
		*/

		var flash_div = document.createElement("div");
		flash_div.id = "luci_communication_applet_div";
		flash_div.style.position = "absolute";
		flash_div.style.top = "0px";
		flash_div.style.left = "0px";
		flash_div.style.width = "1px";
		flash_div.style.height = "1px";
		flash_div.style.overflow = "visible";
		flash_div.style.zIndex = '1';
		flash_div.style.margin = '0';
		flash_div.style.padding = '0';
		flash_div.style.textIndent = '0';
		flash_div.style.borderWidth = '0';
		flash_div.style.borderStyle = 'none';

		flash_div.innerHTML = this.flash_code;
		document.body.appendChild(flash_div);

		window.luci_event_log.add("Connector_Flash", "Flash connector added");
	}
	else
	{
		window.luci_event_log.add('evt', 'starting reinit');
		connector.reinit = true;
	}

	/**
	 * The Adobe way
	 * http://kb2.adobe.com/cps/156/tn_15683.html
	 */
	/*
	function getFlashMovie(movieName) {
		var isIE = navigator.appName.indexOf("Microsoft") != -1;
		return (isIE) ? window[movieName] : document[movieName];
	}
	*/

	connector.get_applet = function()
	{
		/*
		if (document.getElementById("luci_communication_applet_ff") && navigator.userAgent.indexOf('MSIE 9') === -1) {
			window.Luci.connectorId	="luci_communication_applet_ff";
			return document.getElementById("luci_communication_applet_ff");
		}
		*/
		window.Luci.connectorId = 'luci_communication_applet';
		return document.getElementById(window.Luci.connectorId);
	};

	connector.init_connection = function ()
	{
		// init the connection
		if (this.connection_ready) {
			return true;
		}

		var obj = this.get_applet();

		if (this.get_applet()) {
			this.connection_ready = true;
		} else {
			this.connection_ready = false;
		}

		var has_reqested_version = true;//DetectFlashVer(8, 0, 0);
		if (!has_reqested_version)
		{
			this.connection_ready = false;
		}

		if (this.reinit)
		{
			//var rem_div = document.getElementById('luci_communication_applet_div');
			this.reinit = false;
			try
			{
				this.get_applet().reInit();
				window.luci_event_log.add('Comm', "connection reiniting");
			}
			catch (e)
			{
				window.luci_event_log.add('evt', e);
			}

		}

		return this.connection_ready;
	};

	connector.reconnect = function()
	{
		this.reinit					=true;
		this.connection_ready		=false;
		this.init_connection();
	};

	connector.send_command = function(command, compress)
	{
		try
		{
			var applet = connector.get_applet();
			applet.comm_send(command, compress);
		} catch (ex)
		{
			window.luci_event_log.add('evt', 'Error at flash comm_send(): ' + "\n" + ex.toString() + "Command:\n" + command);
		}
	};

	connector.toString = function()
	{
		return "[Flash_connector]";
	};



	return connector;
}

/**
 * JavaScript connection class
 */
function JS_connector(parent)
{
	var connector = new Connector(parent);

	connector.init_connection = function()
	{

		if (window.luci_communicator_js.init())
		{
			this.connection_ready = true;
			return true;
		}
		else
		{
			return false;
		}
	};

	connector.send_command = function (command)
	{
		window.luci_communicator_js.send(command);
	};

	connector.toString = function()
	{
		return "[JS_connector]";
	};

	return connector;
}

/**
 * Cross Domain Request connection class
 */
function XDR_connector(parent)
{
	var connector = new Connector(parent);

	connector.init_connection = function()
	{
		if (window.luci_communicator_xdr.init())
		{
			this.connection_ready = true;
			return true;
		}
		else
		{
			return false;
		}
	};

	connector.send_command = function (command)
	{
		window.luci_communicator_xdr.send(command);
	};

	connector.toString = function()
	{
		return "[XDR_connector]";
	};

	return connector;
}// view json parser

window.Views.toDestroy = [];

function luciViewDestroy(viewArray) {

	var o = window.luciObjectsById[viewArray.id],
		or = (o) ? o.rootElement : null,
		id;

	try {
		o.destroy();
		if (or) {
			or.parentNode.removeChild(or);
		}
	} catch(e) {
		id = parseInt(viewArray.id, 10);
		if (!isNaN(id)) {
			Views.toDestroy.push(id);
			//LUCITODO console
			console.warn(arguments.callee.name, e, 'Could not destroy view. View will not be rendered next time.', viewArray, o);
		} else {
			console.error(arguments.callee.name, e, 'Could not destroy view. Invalid viewArray.id.', viewArray, o);
		}
		return false;
	}

	return true;
}

function destroyWindows(obj)
{
	for (var i = 0; i < window.arraySize(obj.childs); ++i)
	{
		var child = obj.childs[i];
		if (child.viewName == "Window")
		{
			child.onDestroy();
			destroyWindows(child);
		}
	}
}

function luciSleep(milliseconds) {
	var start = new Date().getTime();
	for (var i = 0; i < 1e7; i++) {
		if ((new Date().getTime() - start) > milliseconds){
			break;
		}
	}
}

function luciIncludeNeededJS(viewArray)
{
	window.luci.jsToInclude			=[];
	luciIncludeNeededJSInner(viewArray);

	if (window.luci.jsToInclude.length<30)
	{
		window.luci.include(window.luci.jsToInclude);
	}
	else
	{
		for (var i=0; i<=window.luci.jsToInclude.length; i=i+29)
		{
			var from	=i;
			var to		=i+29;

			if (to >= window.luci.jsToInclude.length)
				{to = window.luci.jsToInclude.length-1;}

			window.luci.include(window.luci.jsToInclude.slice(from, to));
		}
	}
	var counter				=0;
	var treshold			=50;

}

function luciIncludeAddIfNeeded(srcToInclude)
{

	for (var idx in window.luci.jsToInclude)
	{
		if (idx !== undefined)
		{
			var elm	=window.luci.jsToInclude[idx];
			if (elm && elm == srcToInclude)
			{
				return false;
			}
		}
	}

	for (var includedIndex in window.luci.includedScripts)
	{
		if (window.luci.includedScripts[includedIndex] == srcToInclude)
		{
			return false;
		}
	}

	window.luci.jsToInclude.push(srcToInclude);
	return true;
}

function luciIncludeNeededJSInner(viewArray)
{
	luciIncludeAddIfNeeded("Renderers/" + viewArray.rendererMethod);
	luciIncludeAddIfNeeded(viewArray.viewType + "/" + viewArray.viewName);

	for (var i in viewArray.childs)
	{
		luciIncludeNeededJSInner(viewArray.childs[i]);
	}

	if (viewArray.headerChilds)
	{
		for (var i in viewArray.headerChilds)
		{
			luciIncludeNeededJSInner(viewArray.headerChilds[i]);
		}
	}
}

function countBla(viewArray)
{
	window.luci_scriptsLoading++;

	for (var i in viewArray.childs)
	{
		countBla(viewArray.childs[i]);
	}
}

function parseUpdateArray()
{
	if (window.luci_scriptsLoading !== 0 || window.luci.parseLock === true || window.luci.viewArrayStack.length > 0) {
		clearTimeout(window.luci.updateTimer);
		window.luci.updateTimer = setTimeout(function(){ parseUpdateArray(); }, 50);
		return;
	}

	window.luci.parseLock = true;

	while (window.luci.updateArrayStack.length) {
		var viewsToUpdate = window.luci.updateArrayStack.shift();

		for (var viewId in viewsToUpdate) {
			var currentViewData = viewsToUpdate[viewId];

			try {
				window.luciObjectsById[viewId].update(currentViewData);
			}
			catch (e) {
				//window.luci_event_log.addError(e, "Can not update #" + viewId + ".");
				//LUCITODO
				console.error(arguments.callee.name, 'Could not update view #'+ viewId, currentViewData, viewsToUpdate);
			}
		}
	}

	window.luci.parseLock = false;

	return true;
}

function parseViewArray() {
	window.luci.parsing = true;

	/*
	if (typeof window.luci.viewHistory === 'undefined') {
		window.luci.viewHistory = [];
	}
	*/

	if (window.luci_scriptsLoading !== 0 || window.luci.parseLock === true) {
		clearTimeout(window.luci.viewTimer);
		window.luci.viewTimer = setTimeout(function(){ parseViewArray(viewArray); }, 50);
		return;
	}

	window.luci.parseLock = true;

	while (window.luci.viewArrayStack.length) {
		var element = window.luci.viewArrayStack.shift(),
			viewArray = element.viewArray,
			destroy = false,
			i;

		//luci.viewHistory[parseInt(viewArray.id)] = viewArray;

		for (i in Views.toDestroy) {
			if (Views.toDestroy[i] === parseInt(viewArray.id)) {
				destroy = true;
				delete Views.toDestroy[i];
				break;
			}
		}

		if (destroy === true) {
			//LUCITODO
			console.info(arguments.callee.name, 'View will not be rendered.', element);
		} else if (viewArray.parentId !== 'null') {
			try {
				var parentObject = window.luciObjectsById[viewArray.parentId];
				var parentElement = parentObject.canvas;
				window.luciObjectsById[viewArray.parentId].childs[viewArray.id] = viewArray;
				window.Views[viewArray.viewName](viewArray, parentElement);
				window.luciObjectsById[viewArray.parentId].childs[viewArray.id].render();

				window.luciObjectsById[viewArray.parentId].initResize();
				window.luciObjectsById[viewArray.parentId].resized();

				if (parentObject.autoScrollBottom && parentObject.autoScrollBottom == 'true') {
					parentElement.scrollTop = parentElement.scrollHeight;
				}
			} catch(ex) {
				window.luci_event_log.addError(ex, arguments.callee.name +' -- parentId: '+ viewArray.parentId);
			}
		} else {
			try {
				var renderTo;
				var obj = null;

				if (viewArray.htmlTargetId) {
					obj = document.getElementById(viewArray.htmlTargetId);
				}

				if (obj) {
					renderTo = obj;
				} else {
					renderTo = window.luci.getLuciBody();
				}

				window.luciObjects[viewArray.id] = viewArray;
				window.Views[viewArray.viewName](viewArray, renderTo);
				window.luciObjects[viewArray.id].render();
			} catch(e) {
				window.luci_event_log.addError(e, arguments.callee.name +' -- parentId: '+ viewArray.parentId);
			}
		}
	}

	window.luci.parseLock = false;

	if (window.luci.viewArrayStack.length) {
		window.luci.parsing = false;
	}

	return true;
}

function viewStackElement(viewArray)
{
	this.viewArray			=viewArray;
}

function luciViewParser(viewArray)
{
	luciIncludeNeededJS(viewArray);

	window.luci.viewArrayStack.push(new viewStackElement(viewArray));
	window.luci.viewTimer		=setTimeout(function() {parseViewArray();}, 10);
}

var MAX_DUMP_DEPTH = 10;

function dumpObj(obj, name, indent, depth)
{
	if (depth > MAX_DUMP_DEPTH)
	{
		return indent + name + ": <Maximum Depth Reached>\n";
	}

	if (typeof obj == "object")
	{
		var child = null;
		var output = indent + name + "\n";
		indent += "\t";
		for (var item in obj)
		{
			try
			{
				child = obj[item];
			}
			catch (e)
			{
				child = "<Unable to Evaluate>";
			}

			if (typeof child == "object")
			{
				output += dumpObj(child, item, indent, depth + 1);
			}
			else
			{
				output += indent + item + ": " + child + "\n";
			}
		}
		return output;
	}
	else {return obj;}
}


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1) {
					return data[i].identity;
				}
			}
			else if (dataProp) {
				return data[i].identity;
			}
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) {
			return;
		}
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{
			string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{	// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{	// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
function lucifairInit()
{
	window.luciData							=new Array();
	window.luciData['contentDir']			="http://gui2.eos.hu/content/";
	window.luciData['jsDir']				="http://gui2.eos.hu/content/javascript/";
	window.luciData['swfDir']				="http://gui2.eos.hu/content/flash/";
	window.luciData['resizer']				="http://gui2.eos.hu/content/image/resizer/?";
	
	window.luci_event_log					=new luci_event_log_object(false);
	window.luci								=new LuciFair("80.77.126.137", "80", "eos", "orgasmservice", "hu", {"page":"main","logged":"0","destroy_all":"1","partner":"eos","project":"orgasmservice","lang":"en"});
	window.luci.processor					=new LuciCommunicationProcessor();
	var luci								=window.luci;
	window.luciObjects						=new Array();
	window.luciObjectsById					=new Array();

}

setTimeout("lucifairInit()", 100);
